/**
 *
 */
package com.glodon.jcloud.increment.shorturl.api;

import com.glodon.jcloud.common.api.APIResponse;
import com.glodon.jcloud.common.api.ApiStatus;
import com.glodon.jcloud.common.api.Status;
import com.glodon.jcloud.increment.common.cache.CommonCacheOperator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * Terry MicroService
 *
 * Create Date: 2017年9月1日 下午5:51:43
 *
 * @version: V0.0.1-SNAPSHOT
 * @author: Terry.Li
 * @mail: lib-o@glodon.com
 */
public class BaseAPI<T extends Serializable> implements Serializable {

	private static final long serialVersionUID = -8654585406744248476L;

	protected final Logger logger = LoggerFactory.getLogger(getClass());

	@Resource
	protected CommonCacheOperator cache;


	protected APIResponse<T> build(Object object) {
		return APIResponse.build(object);
	}

	protected APIResponse<T> error() {
		return APIResponse.error();
	}

	protected APIResponse<T> error(Status status) {
		return APIResponse.error(status);
	}

	protected APIResponse<T> success() {
		return APIResponse.build(ApiStatus.OK);
	}

	protected APIResponse<T> success(Object object) {
		return build(object);
	}
}
